﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 出货绑定
{
    public class Db2_2
    {
        private ConnectionConfig connection = null;
        public SqlSugarClient db = null;
        public Db2_2()
        {
            string SqlIP = "192.168.2.2";
            string database = "MESDB";
            string uid = "sa";
            string pwd = "8ik,9ol.";
            connection = new ConnectionConfig()
            {
                ConnectionString = "server='" + SqlIP + "';initial catalog='" + database + "';uid='" + uid + "';pwd='" + pwd + "'",
                DbType = DbType.SqlServer,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            };
            db = new SqlSugarClient(connection);
        }
        public t_DD_UserDetail GetUser(string jobnumber)
        {
            try
            {
                return db.Queryable<t_DD_UserDetail>().Where(it => it.jobnumber == jobnumber && it.companyName == "重庆盟讯电子科技有限公司").First();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #region t_DD_UserDetail
        [SugarTable("t_DD_UserDetail")]
        public class t_DD_UserDetail
        {
            public string username { get; set; }
            public string jobnumber { get; set; }
            public string companyName { get; set; }
        }
        #endregion
    }
}
